package com.mbc.controller;


import com.github.pagehelper.PageInfo;
import com.mbc.comment.Result;
import com.mbc.dto.RoughAnimalInfoDTO;
import com.mbc.service.UserPublishedAnimalService;
import com.mbc.vo.DetailsAnimalInfoVO;
import com.mbc.vo.RoughAnimalInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

/**
 * <p>
 * 用户发布流浪动物表 前端控制器
 * </p>
 *
 * @author suimeng
 * @since 2024-04-15
 */
@RestController
@RequestMapping("/publishAnimal")
@Api(tags = "用户发布流浪动物接口")
@CrossOrigin
public class UserPublishedAnimalController {

    @Autowired
    private UserPublishedAnimalService userPublishedAnimalService;

    /**
     * 查询粗糙动物信息
     *
     * @param roughAnimalInfoDTO 粗糙动物信息 DTO
     * @param page               页
     * @param size               大小
     * @return {@link Result}<{@link PageInfo}<{@link RoughAnimalInfoVO}>>
     */
    @GetMapping("/RoughAnimalInfo")
    @ApiOperation("分类查询流浪动物")
    public Result<PageInfo<RoughAnimalInfoVO>> getByRoughAnimalInfo(RoughAnimalInfoDTO roughAnimalInfoDTO, @RequestParam(defaultValue = "1") Integer page , @RequestParam(defaultValue = "10") Integer size){
        PageInfo<RoughAnimalInfoVO> list = userPublishedAnimalService.getByRoughAnimalInfo(roughAnimalInfoDTO,page,size);
        return Result.success(list);
    }

    /**
     * 查询详细信息动物信息
     *
     * @param animalId 动物 ID
     * @return {@link Result}<{@link DetailsAnimalInfoVO}>
     */
    @GetMapping("/DetailsAnimalInfo/{animalId}")
    @ApiOperation("根据宠物名称详细查询流浪动物")
    public Result<DetailsAnimalInfoVO> getByDetailsAnimalInfo(@PathVariable Integer animalId){
        DetailsAnimalInfoVO detailsAnimalInfoVO = userPublishedAnimalService.getByDetailsAnimalInfo(animalId);
        return Result.success(detailsAnimalInfoVO);
    }
}
